View on GitHub

Super-bowl-50-twitter-statistics

Some statistics taken using Twitter StreamingAPI to see Twitter user reactions to Super Bowl events

Download this project as a .zip file Download this project as a tar.gz file

Creating Figures in R

We used R Studio to create the various graphs seen in this project. Once the data was transformed into the csv files we imported it into R Studio. Once in R studio we converted the timestamp_ms field to Eastern Standard Time. Then we created subsets of the data frames according to certain keywords. Due to R’s weirdness we used regex to select the tweets we wanted in out subsets. The code we used to do this can be seen below.

        
commercials$tweet_ms <- as.POSIXct(commercials$tweet_ms/1000, origin = "1970-1-1")

doritos <- commercials[grep("[Dd]orito[*s]", commercials$tweet_text, perl=TRUE),]

hist(doritos$tweet_ms, breaks = 100, xlab = "Time of Tweet", main = "Frequency of Tweets Referencing Doritos", freq = TRUE)